﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace SocialRede.Controls
{
    public partial class UserFriends : System.Web.UI.UserControl
    {
        public DataTable dt;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                GetAmigos(Voluntariar.WEB.Util.Sessao.ObjUsuario.ID);
            }
        }

        public void GetAmigos(int Id)
        {
            try
            {
                dt = new Voluntariar.Sistema.DAO.UsuarioDAO().PesquisaUsuarioDT(Id);
                if (dt.Rows.Count > 0)
                {
                    rpt.DataSource = dt;
                    rpt.DataBind();
                }
            }
            catch (Exception)
            {
                throw;
            }
            
        }

        public string getHREF(object sURL)
        {
            DataRowView dRView = (DataRowView)sURL;
            string Id = dRView["Id"].ToString();
            return ResolveUrl("~/UserDetais.aspx?Id=" + Id);
        }

        public string getSRC(object imgSRC)
        {
            DataRowView dRView = (DataRowView)imgSRC;
            string ImageName = dRView["ImageName"].ToString();
            if (ImageName == "NoImage")
            {
                return ResolveUrl(@"~/ImagemUsuarios/missing.jpg");
            }
            else
            {
                return ResolveUrl("~/ImagemUsuarios/" + dRView["ImageName"].ToString());
            }
        }
    }
}